﻿
@{
    Layout = null;
    ViewData["Title"] = "ShanChuHuiFu";
}
<script src="~/js/vue.js"></script>
<script src="~/js/axios.js"></script>
<script src="~/element-ui/lib/index.js"></script>
<link rel="stylesheet" href="~/element-ui/lib/theme-chalk/index.css" />
<div id="app">
    <el-card class="box-card">
        <div slot="header" class="clearfix">
            <span>您正在做的业务是：人力资源--人力资源档案管理--人力资源档案删除管理-人力资源档案删除</span>
        </div>
        <div>
            <el-descriptions :column="3" style="width:90%;" border>
                <el-descriptions-item>
                    <template slot="label">
                        I、II、III级机构
                    </template>
                    <el-cascader expand-trigger="hover"
                                 :options="jiGouData"
                                 :props="jiGouProps"
                                 v-model="jiGouKeys"
                                 v-on:change="JiGouChanged"
                                 clearable
                                 change-on-select
                                 ref="jigou">
                    </el-cascader>
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        请选择职位分类
                    </template>
                    <el-cascader expand-trigger="hover"
                                 :options="HeBingData"
                                 :props="cascaderProps"
                                 v-model="selectedKeys"
                                 v-on:change="parentCateChanged"
                                 clearable
                                 change-on-select
                                 ref="casc">
                    </el-cascader>
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        关键字
                    </template>
                    <el-input style="width:100%" v-model="guanJianZi"></el-input>
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label">
                        请输入建档时间
                    </template>
                    <el-date-picker type="date" style="width:35%" placeholder="选择日期" v-model="time1"></el-date-picker>至
                    <el-date-picker type="date" style="width:35%" placeholder="选择日期" v-model="time2"></el-date-picker>(YYYY-MM-DD)
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <el-button type="primary" v-on:click="TiaoJian()">查询</el-button>
                </el-descriptions-item>
            </el-descriptions>
            @*查询*@
            <el-table :data="tableData"
                      style="width: 100%"
                      v-show="isShow">
                <el-table-column prop="huf_id"
                                 label="档案主键"
                                 width="180"
                                 v-if="false">
                </el-table-column>
                <el-table-column prop="human_id"
                                 label="档案编号"
                                 width="180">
                </el-table-column>
                <el-table-column prop="human_name"
                                 label="姓名"
                                 width="180">
                </el-table-column>
                <el-table-column prop="first_kind_name"
                                 label="I级机构"
                                 width="180">
                </el-table-column>
                <el-table-column prop="second_kind_name"
                                 label="II级机构"
                                 width="180">
                </el-table-column>
                <el-table-column prop="third_kind_name"
                                 label="III级机构"
                                 width="180">
                </el-table-column>
                <el-table-column prop="human_major_kind_name"
                                 label="职位分类"
                                 width="180">
                </el-table-column>
                <el-table-column prop="human_major_name"
                                 label="职位名称"
                                 width="180">
                </el-table-column>
                <el-table-column prop="regist_time"
                                 label="建档时间"
                                 width="180">
                    <template v-if="(scope.row.regist_time!='0001-01-01T00:00:00')" slot-scope="scope">{{scope.row.regist_time | dateFormat}}</template>
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button size="primary"
                                   v-on:click="XiuGai(scope.row)">修改</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </el-card>
    <!--修改模态框-->
    <el-dialog title="修改"
               :visible.sync="UpdateFrom"
               width="50%">
        <span>
            <el-form :model="Update" :rules="urules" ref="Update" label-width="100px" class="demo-ruleForm">
                <el-form-item label="主键" prop="Huf_id" v-if="false">
                    <el-input readonly v-model="Update.Huf_id"></el-input>
                </el-form-item>
                <el-form-item label="档案编号" prop="Human_id">
                    <el-input readonly v-model="Update.Human_id"></el-input>
                </el-form-item>
                <el-form-item label="姓名" prop="Human_name">
                    <el-input v-model="Update.Human_name"></el-input>
                </el-form-item>
                <el-form-item label="恢复时间" prop="Recovery_time">
                    <el-input readonly v-model="Update.Recovery_time"></el-input>
                </el-form-item>
            </el-form>
        </span>
        <span slot="footer" class="dialog-footer">
            <el-button v-on:click="UpdateFrom = false">取 消</el-button>
            <el-button type="primary" v-on:click="UpdateOk()">确 定</el-button>
        </span>
    </el-dialog>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            tableData: [],
            //级联属性
            jiGouData: [],
            HeBingData: [],
            jiGouProps: {
                value: "id",
                label: "name",
                children: "children",
            },
            cascaderProps: {
                value: "id",
                label: "name",
                children: "children",
            },
            jiGouKeys: [],
            selectedKeys: [],
            //查询开关
            isShow: false,
            guanJianZi: "",
            time1: "",
            time2: "",
            gou: [],
            zhi: [],
            UpdateFrom:false,
            Update:{
                Huf_id:"",
                Human_id:"",
                Human_name:"",
                Recovery_time:""
            },
            urules:{},
        },
        methods: {
            //条件查询 点击打开查询
            TiaoJian() {
                this.isShow = true;
                //console.info(this.zhi)
                axios.get("/RenLiZiYuanDangAnGuanLi/HuiFuFind", { params: { one: this.gou[0], two: this.gou[1], three: this.gou[2], name: this.guanJianZi, type: this.zhi[0], minCheng: this.zhi[1], time1: this.time1, time2: this.time2 } }).then(res => {
                    //console.info(res.data);
                    this.tableData = res.data;
                })
            },
            //状态转换
            //selectState(rows) {
            //    if (rows.check_status == 0) return "不通过"
            //    if (rows.check_status == 1) return "通过"
            //},
            //时间过滤器方法
            TimeGuoLvQi() {
                // 定义时间过滤器，
                Vue.filter('dateFormat', function (originDate, pattern = '') {
                    // 根据给定的时间字符串，得到特定的时间
                    var dt = new Date(originDate)
                    //   yyyy-mm-dd
                    var y = dt.getFullYear()
                    var m = (dt.getMonth() + 1).toString().padStart(2, '0')
                    var d = dt.getDate().toString().padStart(2, '0')
                    if (pattern.toLowerCase() === 'yyyy-mm-dd') {
                        return `${y}-${m}-${d}`
                    } else {
                        var hh = dt.getHours().toString().padStart(2, '0')
                        var mm = dt.getMinutes().toString().padStart(2, '0')
                        var ss = dt.getSeconds().toString().padStart(2, '0')
                        //return `${y}-${m}-${d}`
                        return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
                    }
                })
            },
            //一二三级下拉框 查询方法
            FindJiGou() {
                axios.get("/ZhiWeiFaBuDengJi/HeBing").then(res => {
                    this.jiGouData = res.data;
                })
            },
            //一二三级下拉框  改变事件
            JiGouChanged() {
                //选中值有就大于0
                if (this.jiGouKeys.length > 0) {
                    //获取键
                    this.ji = this.jiGouKeys;
                    //console.info(this.jiGouKeys);
                    //获取值
                    this.gou = this.$refs["jigou"].getCheckedNodes()[0].pathLabels;
                    //console.info(this.$refs["jigou"].getCheckedNodes()[0].pathLabels);
                }
            },
            //职位分类 职位名称 查询方法
            FindHeBing() {
                axios.get("/JianLiGuanLi/HeBing").then(res => {
                    this.HeBingData = res.data;
                })
            },
            //职位分类，职位名称  改变事件
            parentCateChanged() {
                //选中值有就大于0
                if (this.selectedKeys.length > 0) {
                    //获取键
                    this.key = this.selectedKeys;
                    //console.info(this.selectedKeys);
                    //获取值
                    this.zhi = this.$refs["casc"].getCheckedNodes()[0].pathLabels;
                    //console.log(this.zhi)
                }
            },//时间
            tick() {
                var d = new Date();
                var y = d.getFullYear();
                var moth = d.getMonth() + 1;
                var date = d.getDate();
                var h = d.getHours();
                var m = d.getMinutes();
                var s = d.getSeconds();
                var hh = 20 - 1 - h;
                var mm = 60 - 1 - m;
                var ss = 60 - s;
                if (hh > 0) {
                    mm = mm + 60 * hh;
                }
                if (moth < 10) {
                    moth = "0" + moth;
                }
                if (date < 10) {
                    date = "0" + date;
                }
                if (h < 10) {
                    h = "0" + h;
                }
                if (m < 10) {
                    m = "0" + m;
                }
                if (s < 10) {
                    s = "0" + s;
                }
                if (mm < 10) {
                    mm = "0" + mm;
                }
                if (ss < 10) {
                    ss = "0" + ss;
                }
                this.Update.Recovery_time = y + " - " + moth + " - " + date + " " + h + ": " + m + ": " + s;
            },
            //修改
            XiuGai(row) {
                this.Update.Huf_id=row.huf_id;
                this.Update.Human_id=row.human_id;
                this.Update.Human_name=row.human_name;
                //打开模态框
                this.UpdateFrom=true;
            },
            //点击修改模态框的确定
            UpdateOk(){
                axios.get("/RenLiZiYuanDangAnGuanLi/HuiFuStatus", { params: { huf_id: this.Update.Huf_id, human_name: this.Update.Human_name, recovery_time: this.Update.Recovery_time, delete_status: 0 } }).then(res => {
                    if(res.data>0){
                        alert("恢复成功");
                        //关闭模态框
                        this.UpdateFrom=false;
                        //跳到永久删除页面
                        location.href="/RenLiZiYuanDangAnGuanLi/YongJiuShanChu";
                    }
                })
            }
        },
        mounted() {
            window.onload = this.tick;
            var out = window.setInterval(this.tick, 1000);
            this.FindJiGou();
            this.FindHeBing();
            this.TimeGuoLvQi();
        }
    })
</script>
<style scoped>
    .el-descriptions-item__label.is-bordered-label {
        background: #FFD553;
        color: black;
    }

    .el-descriptions {
        height: 240px;
    }
</style>


